<template>
  <div class="daily-goods ">
    <div class="dy-header">
      <span>优惠专区</span>
      <span class="for-more border">查看更多</span>
    </div>
    <div class="dy-body">
      <div class="dy-item" v-for="(item,index) in list" :key="item.id" @click="handleClick(item.id)">
        <div class="dy-body-img" @mouseenter="enter(index)" @mouseleave="leave()">
          <img :src="item.imgUrl" :title="item.name" :alt="item.name" :class="showMask && currentIndex === index ? 'scale-img' : '' " >
        </div>
        <div class="mask" v-if="showMask && currentIndex === index"
             @mouseenter="enter(index)"
             @mouseleave="leave()
             ":title="item.name">
          <i class="el-icon-search"></i>
        </div>
        <div class="img-desc">
          <span class="bargain border" v-if="item.bargains">特价</span>
          <span class="bargain border" v-if="item.isHot">热门</span>
          <span class="goods-name">{{ item.name}}</span>
          <p>
            <span>¥</span> <span>{{ item.price | money }}</span>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "Daily",
    data () {
      return {
        showMask: false,
        currentIndex: ''
      }
    },
    methods: {
      handleClick (id) {
        this.$router.push({path: '/goods_info/', query: {itemId: id}})
      },
      enter (index) {
        this.currentIndex = index;
        this.showMask = true;
      },
      leave () {
        this.showMask = false;
        this.currentIndex = ''
      }
    },
    props: {
      list: {
        type: Array,
        default: []
      }
    }
  }
</script>

<style lang="stylus" scoped>
  @import '~@/assets/css/common.styl'
  /*  优惠专区  */
  .daily-goods {
    padding: $commonPadding;
  }
  .dy-header {
    padding: 20px 5px;
  }
  .dy-body {
    position: relative;
  }
  .dy-item {
    display: inline-block;
    width: 24%;
    margin: 0 5px;
    text-align: center;
    position: relative;
  }
  .dy-body-img {
    overflow: hidden
  }
  .dy-body-img img {
    width: 100%;
    background: #fbfbfb;
    transition: all .6s;
  }
  .scale-img{
    transform: scale(1.1);
  }
  .mask {
    background: rgba(76, 76, 76, 0.44);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 62px;
    line-height: 263px;
    font-size: 30px;
    color: #ffc904;
    cursor: pointer
  }
  .img-desc {
    margin-top: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 260px;
    line-height: 24px;
  }
  .img-desc span.bargain {
    font-size: 12px;
    font-weight: 400;
    font-family: sans-serif;
    color: #f00;
    padding: 0px 5px;
  }
  .img-desc span.border:before {
    border-color: #f00;
    border-radius: 5px;
  }
  .img-desc span.goods-name {
    font-size: 14px;
  }
  .img-desc p {
    margin: 0;
    font-size: 12px

  }
  .img-desc p span:last-child {
    color: #f00;
    font-size: 14px;
  }
  /*更多内容*/
  .for-more {
    font-size 12px;
    float: right;
    margin-right: 20px;
    padding: 4px 10px;
    background: #ccacac;
    color: #fff;
    border-radius: 6px;
  }
  .for-more:before {
    border-radius: 10px;
  }
  .for-more:hover {
    background: #e8c6c6;
    cursor: pointer;
  }
</style>
